package com.systemic.utils;

import java.net.URI;

/**
 * @ClassName: UidExtractorUtils
 * @Description:
 * @Author:
 * @CreateTime: 2024-01-02 18:58
 * @Version:
 **/
public class UidExtractorUtils {
    public static String extractUid(URI uri) {
//        assert uri != null;
        String query = uri.getQuery();
        if (query != null) {
            String[] params = query.split("&");
            for (String param : params) {
                if (param.startsWith("uid=")) {
                    return param.substring(4);
                }
            }
        }
        return null; // or throw an exception, depending on your requirements
    }

    public static String makeUid(String queryString) {
        if (queryString != null) {
            String[] params = queryString.split("&");
            for (String param : params) {
                String[] keyValue = param.split("=");
                if (keyValue[0].equals("uid")) {
                    return keyValue[1];
                }
            }
        }
        return null; // or throw an exception, depending on your requirements
    }
}
